//
//  DiscoverCollectionViewCellOfContentViewFifth.m
//  XYFMApp
//
//  Created by 岁变 on 16/8/31.
//  Copyright © 2016年 岁变. All rights reserved.
//

#import "DiscoverCollectionViewCellOfContentViewFifth.h"
#import "XYMacro.h"

@implementation DiscoverCollectionViewCellOfContentViewFifth

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        _picImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_picImageView];
        
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textColor = [UIColor whiteColor];
        _titleLabel.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:_titleLabel];
        
        _fromLabel = [[UILabel alloc] init];
        _fromLabel.textColor = [UIColor grayColor];
        _fromLabel.font = [UIFont systemFontOfSize:13];
        [self.contentView addSubview:_fromLabel];
        
    }
    return self;
}

- (void)setModel:(DiscoverModelFirstRecommend *)model {
    
    _titleLabel.text = model.item_name;
    _fromLabel.text = [NSString stringWithFormat:@"From: %@", model.item_manager];
    [_picImageView sd_setImageWithURL:[NSURL URLWithString:model.item_img] placeholderImage:PLACEHOLDERIMAGE];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    [_picImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo (self.contentView.mas_top).with.offset(0);
        make.left.equalTo(self.contentView.mas_left).with.offset(0);
        make.right.equalTo(self.contentView.mas_right).with.offset(0);
        make.height.equalTo(_picImageView.mas_width);
    }];
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_picImageView.mas_bottom).with.offset(0);
        make.left.equalTo(self.contentView.mas_left).with.offset(0);
        make.right.equalTo(self.contentView.mas_right).with.offset(0);
        make.height.mas_offset(20);
    }];
    
    [_fromLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_titleLabel.mas_bottom).with.offset(0);
        make.left.equalTo(self.contentView.mas_left).with.offset(0);
        make.right.equalTo(self.contentView.mas_right).with.offset(0);
        make.height.mas_offset(15);
    }];
}

@end
